<?php
/**
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; version 3 of the License.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 */

/**
 * Mobile detect gateway
 * @package Util
 * @author Vincze Tamás pilou@pilou.hu
 * @version 0.1.0
 */
namespace Util\Mobile;

if (!include_once(DIR_LIB . "/Util/Mobile/Mobile_Detect.php")) {
	trigger_error("Failed to load Mobile Detect.", E_USER_ERROR);
}
class Detect extends \Mobile_Detect {

	/**
	 * Class instance
	 * @var \Util\Mobile\Detect
	 */
	protected static $_instance;
	
	/**
	 * Returns with instance of class.
	 * @access public
	 * @access static
	 * @return \Util\Mobile\Detect
	 */
	public static function getInstance(){
		if (is_null(static::$_instance)){
			static::$_instance = new self();
		}
		return static::$_instance;
	}
	
	/**
	 * Wrapper for public function calling
	 * @param string $functionName
	 * @return bool
	 */
	protected static function _getPublicFunction($functionName){
		return static::getInstance()->__call($functionName, array());
	}
	
	/**
	 * Gets if mobile device is the HTTP requester
	 * @return bool
	 */
	public static function isMobileDevice(){
		return static::getInstance()->isMobile();
	}
	
	/**
	 * Gets if an android device is the HTTP requester
	 * @return bool
	 */
	public static function isAndroid(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if an android tablet device is the HTTP requester
	 * @return bool
	 */
	public static function isAndroidtablet(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if an iPhone device is the HTTP requester
	 * @return bool
	 */
	public static function isIphone(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if an iPad device is the HTTP requester
	 * @return bool
	 */
	public static function isIpad(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if a BlackBerry device is the HTTP requester
	 * @return bool
	 */
	public static function isBlackberry(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if a BlackBerry tablet device is the HTTP requester
	 * @return bool
	 */
	public static function isBlackberrytablet(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if Palm device is the HTTP requester
	 * @return bool
	 */
	public static function isPalm(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if a windows phone device is the HTTP requester
	 * @return bool
	 */
	public static function isWindowsphone(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if a windows device is the HTTP requester
	 * @return bool
	 */
	public static function isWindows(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
	/**
	 * Gets if device is none of the other devices, but it's a mobile device
	 * @return bool
	 */
	public static function isGeneric(){
		return static::_getPublicFunction(__FUNCTION__);
	}
	
}
?>